<script>
	var iosSessionId = 0;
	import Vue from 'vue'
	export default {
		onLaunch: function() {
			const updateManager = uni.getUpdateManager()
			updateManager.onCheckForUpdate(function(res) {
				// 请求完新版本信息的回调
				console.log(res.hasUpdate)
			})
			// 下载新版本
			updateManager.onUpdateReady(function() {
				uni.showModal({
					title: '更新提示',
					content: '新版本已经准备好，是否重启应用？',
					success(res) {
						if (res.confirm) {
							// 重启应用
							updateManager.applyUpdate()
						}
					},
				})
			})
			// 新版本下载失败
			updateManager.onUpdateFailed(function(res) {
				// 新的版本下载失败
				uni.showModal({
					title: '已经有新版本了哟~',
					content: '新版本已经上线啦~，请您删除当前小程序，重新搜索打开哟~',
				})
			})
			// var that = this
			// that.setAppInfo()
			// // #ifdef APP-PLUS
			// plus.push.addEventListener('click', function(msg) {
			// 	// console.log('用户点击了', msg)
			// 	// 安卓离线通知被点击可能会触发两次click,第一次的msg.payload为莫名obj
			// 	if ((msg.payload && Object.prototype.toString.call(msg.payload) !== '[object Object]') || iosSessionId) {
			// 		let messageShow = () => {
			// 			let sessionId = (iosSessionId ? iosSessionId:msg.payload)
			// 			if (parseInt(sessionId) == 0) {
			// 				uni.switchTab({
			// 					url: '/pages/message/message'
			// 				})
			// 				return ;
			// 			}
			// 			uni.navigateTo({
			// 				url: '/pages/session-info/session-info?id=' + sessionId
			// 			})
			// 		}
			// 		let pages = getCurrentPages(), page = pages[pages.length - 1]
			// 		if (page && page.route == 'pages/message/message') {
			// 			messageShow()
			// 		} else {
			// 			that.ws.messageReady = messageShow
			// 		}
			// 	}
			// }, false)
			
			// let platform = that.ws.userPlatform ? that.ws.userPlatform:uni.getSystemInfoSync().platform
			// if (platform == 'ios') {
			// 	plus.push.addEventListener("receive", function(msg) {
			// 		if ('ignore' == msg.payload) {
						
			// 		} else {
			// 			//接收透传消息
			// 			iosSessionId = msg.payload;
			// 			plus.push.createMessage(msg.content, 'ignore', {
			// 				title: msg.title,
			// 				cover: false
			// 			});
			// 		}
			// 	}, false);
			// }
			// // #endif
			
			// uni.onNetworkStatusChange(function (res) {
			//     if (res.isConnected) {
			// 		const userinfo = uni.getStorageSync('userinfo');
			// 		if (userinfo) {
			// 			that.ws.init(userinfo.token, userinfo.auth_token)
			// 		}
			// 	} else {
			// 		that.ws.socketTask.close()
			// 		that.ws.socketOpen = false
			// 		that.ws.checkNetwork()
			// 	}
			// });
			
		},
		onShow: function(query) {
			// // #ifdef APP-PLUS
			// plus.runtime.setBadgeNumber(0);
			// // #endif
			// if (query.path != 'bundle/pages/login/login' && query.path != 'pages/center/register') {
			// 	this.ws.pageRefresh.message = true
			// 	this.ws.pageRefresh.sessionInfo = true
			// 	this.checkLogin()
			// }
		},
		methods: {
			async setAppInfo() {
				let that = this
				return new Promise((resolve, reject) => {
					uni.getSystemInfo({
						success: function(e) {
							Vue.prototype.StatusBar = e.statusBarHeight
							// #ifdef H5
							Vue.prototype.CustomBar = e.statusBarHeight + 45
							// #endif
			
							// #ifdef APP-PLUS
							if (e.platform == 'android') {
								Vue.prototype.CustomBar = e.statusBarHeight + 50
							} else {
								Vue.prototype.CustomBar = e.statusBarHeight + 45
							}
							// #endif
			
							// #ifdef MP-WEIXIN
							let custom = wx.getMenuButtonBoundingClientRect()
							Vue.prototype.Custom = custom
							Vue.prototype.CustomBar = custom.bottom + custom.top - e
								.statusBarHeight
							// #endif
						},
					})
				})
			},
			
			checkLogin: function () {
				const userinfo = uni.getStorageSync('userinfo');
				var valid = true;
				if (!userinfo || !userinfo.token) {
					valid = false;
				} else {
					let token = userinfo.token.split('|');
					let time = Date.parse(new Date()).toString();
					time = time.substr(0,10);
					// 减去一秒,防止刚好到时间造成发送了错误的请求
					if ((parseInt(token[2]) - 2) < parseInt(time)) {
						valid = false;
					}
				}
				
				if (!valid) {
					setTimeout(() => {
						this.ws.logout()
					}, 300)
				} else {
					this.ws.init(userinfo.token, userinfo.auth_token)
				}
			}
		}
	}
</script>

<style lang="scss">
	@import "uview-ui/index.scss";
	
	page {
		background-color: #ffffff;
		padding-bottom: 120rpx;
	}
	
	
	.nav .cu-item.cur {
		position: flex;
		z-index: 9;
		color: #01EA9B;
		border-radius: 6upx;
		border-bottom: 6upx solid #01EA9B;
	}
	
	
	.reuires-label {
		font-size: 28rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		margin-right: 10upx;
		color: #FF3125;
		line-height: 40upx;
	}
	
	.bototm-btn-radius {
	
		height: 90upx;
		background: $base-color;
		border-radius: 16upx;
		font-size: 28upx;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 500;
		color: #ffffff;
		line-height: 90upx;
	}
	
	/* 去除scroll滚动条 */
	::-webkit-scrollbar {
		width: 0;
		height: 0;
		background-color: transparent;
	}
	
	.nav .cu-item.cur {
		position: flex;
		z-index: 9;
		color: #01EA9B;
		border-radius: 6upx;
		border-bottom: 6upx solid #01EA9B;
	}
	
	.leftArrowImage {
		width: 50rpx;
		height: 50rpx;
		margin-top: 100rpx;
		margin-left: 30rpx;
		// background-size: 100% 100%;
		// background-image: url(static/home/left.png);
	}
	
	.topBG {
		// padding-top: 10px;
	
		/* #ifdef MP||APP-PLUS */
		// padding-top: $top;
		/* #endif */
	
		// margin-top: -160rpx;
		height: 294rpx;
	
		// background-image: url('./static/common/bg.png');
		// background-image: url('/static/common/topBg.png');
		background-size: 100% 100%;
		// background-color: #567890;
	}
	
	.navView {
		height: 54px;
		padding-top: 10px;
		/* #ifdef MP||APP-PLUS */
		padding-top: $top;
		// height: 94px;
		/* #endif */
	
	
	}
	
	.navView1 {
		padding: 0 34rpx;
		height: 44px;
	}
	
	.topBG1 {}
	
	.topView1 {
		height: 160rpx;
	}
	
	.bg-red-content {
		background-color: #e54d42 !important;
		color: #ffffff;
		font-size: 24upx;
		vertical-align: middle;
		position: absolute;
		top: 10upx;
		right: 30upx;
		display: inline-flex;
		align-items: center;
		justify-content: center;
		box-sizing: border-box;
		// padding: 0upx 16upx;
		height: 40upx;
		width: 40upx;
		font-family: Helvetica Neue, Helvetica, sans-serif;
		white-space: nowrap;
	
	}
	
	
	
	.baseColor {
		color: $base-color;
	}
	
	.arrow {
		width: 28rpx;
		height: 28rpx;
	}
	
	.phone {
		width: 60rpx;
		height: 60rpx;
	}
	
	.leftButton {
		padding-top: 26rpx;
		margin-left: 26rpx;
		/* #ifdef MP||APP-PLUS */
		padding-top: $top;
		/* #endif */
		z-index: 999;
	}
	
	.leftButton1 {
		margin-top: 126rpx;
		margin-left: 26rpx;
		width: 56rpx;
		height: 56rpx;
		background: #00000080;
		border-radius: 50%;
	
		z-index: 999;
	}
	.status_bar {
		height: var(--status-bar-height);
		width: 100%;
	}
	
	.headerBar {
		padding-top: var(--status-bar-height);
	}
	
	.footer {
		position: fixed;
		bottom: 0px;
		left: 0;
		right: 0;
		z-index: 99;
		// calc(var(--status-bar-height) + 60px);
		padding-bottom: env(safe-area-inset-bottom);
		// padding-bottom:calc( env(safe-area-inset-bottom)+ 10px);
	}
	.bottomButton{
			margin: 40rpx;
			margin-bottom: 0rpx;
			height: 100rpx;
			background: $base-color;
			border-radius: 36rpx;
			opacity: 1;
			font-size: 30rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 500;
			color: #FFFFFF;
		}
	
	.user-status-0 {
	    color: $--gray !important;
	}
	.user-status-1 {
	    color: #21E589 !important;
	}
	.user-status-2 {
	    color: #FF647E !important;
	}
	.user-status-3 {
	    color: #FF9C4E !important;
	}
	.im-data-none {
		display: block;
		line-height: 100rpx;
		text-align: center;
		font-size: 28rpx;
		color: $--gray;
	}
	.cuIcon-round:before {
		content: "\e6d7";
	}
	.cuIcon-roundcheckfill:before {
		content: "\e656";
	}
</style>
